This project seeks to visualise data in the way of a collection of articles covering studies in smarter farming. The articles was collected throughout the spring of 2023, and covers a number of different experiments, literary reviews, and studies pertaining to how farmers and other actors in the industry view the growing possibilities in precision agriculture technologies.

The collection of articles was made in collaboration with researchers at Aarhus University, and will be updated even after the hand-in of this project. The articles will pulled from a Google sheet, but please notice that a chunk of code, where the articles are read in as an Excel file, has been added for offline work, and can be uncommented for this purpose.

The articles data contains 9 columns:

Besides the articles data the project also makes use of a GeoJSON file containing polygons for all the worlds countries. This file is essential for visualising the articles data, as the aim is to show the country of origin of all articles in an easy to view format. The file was pulled from the following GitHub repository:

https://github.com/datasets/geo-countries

The countries data contains three columns:

For further description of the data I refer to the XXX section in the project paper.

MAYBE ALREADY DESCRIBE THE MAPS HERE

Preparing data

In order to visualise the data in a meaningful way I first need to prepare it. First step is reading in the necessary libraries and then read in the data and inspect it.

library(leaflet)
library(readxl)
library(sf)
library(RColorBrewer)
library(dplyr)
library(htmltools)
library(tidyverse)
library(ggplot2)
library(ggnewscale)
# reading file containing articles' information including country
articles <- read_excel("data/articles.xlsx")
articles
# A tibble: 62 × 9
   Author    Year Title Journal Abstract Keywords Country Questionnaire/Interv…¹
   <chr>    <dbl> <chr> <chr>   <chr>    <chr>    <chr>   <chr>                 
 1 Ammann,…  2023 Data… Data i… The art… Digital… Switze… Yes                   
 2 Finger,…  2019 Prec… Annual… Precisi… Big dat… Switze… No                    
 3 Rijswij…  2019 Digi… NJAS -… Digital… Advisor… New Ze… Yes                   
 4 Michels…  2020 Smar… Precis… This st… Digital… Germany Yes                   
 5 Ciruela…  2020 Digi… Sustai… This pa… Coopera… Spain   No                    
 6 Newton,…  2020 Farm… Agricu… This pa… Collabo… Austra… No                    
 7 Zhang, …  2023 Can … Enviro… This st… Agricul… China   Yes                   
 8 Groher …  2020 Digi… Animal  This st… Farm ch… Switze… Yes                   
 9 Pfeiffe…  2021 Unde… Agricu… This st… Dairy; … Germany Yes                   
10 Groher,…  2020 Stat… Precis… This pa… Digital… Switze… Yes                   
# ℹ 52 more rows
# ℹ abbreviated name: ¹​`Questionnaire/Interview`
# ℹ 1 more variable: URL <chr>
# reading GeoJSON file containing country boundaries
countries <- st_read("data/countries.geojson")
Reading layer `countries' from data source 
  `/Users/miakuntz/Documents/UNI/6. semester/spatial_analytics/final_project/spatial_final_proj/data/countries.geojson' 
  using driver `GeoJSON'
Simple feature collection with 255 features and 2 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
Geodetic CRS:  WGS 84
countries
Simple feature collection with 255 features and 2 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
Geodetic CRS:  WGS 84
First 10 features:
                  ADMIN ISO_A3                       geometry
1                 Aruba    ABW MULTIPOLYGON (((-69.99694 1...
2           Afghanistan    AFG MULTIPOLYGON (((71.0498 38....
3                Angola    AGO MULTIPOLYGON (((11.73752 -1...
4              Anguilla    AIA MULTIPOLYGON (((-63.03767 1...
5               Albania    ALB MULTIPOLYGON (((19.74777 42...
6                 Aland    ALA MULTIPOLYGON (((20.92018 59...
7               Andorra    AND MULTIPOLYGON (((1.707006 42...
8  United Arab Emirates    ARE MULTIPOLYGON (((53.86305 24...
9             Argentina    ARG MULTIPOLYGON (((-68.65412 -...
10              Armenia    ARM MULTIPOLYGON (((45.54717 40...

The articles data is read in as a data frame, and at first inspection seems to have everything it should have included. The countries file is read in as a simple feature object with 255 features and 2 fields. Its a multipolygon, which means that the countries geometry is a collection of multiple polygons. The dimension of the data is a two dimensional coordinate system “XY”, where the bounding box values show that it covers nearly the whole world. The coordinate reference system (CRS) of the data is WGS84, which is typical when working with global spatial data.

Next part of the code focuses on preparing the data to be visualised. I first split those rows in the “Country” column which has several countries in it so to be able to credit all countries responsible for that particular article when they are visualised in the maps. I thereafter unnest those arrays into their own set of rows. Lastly, I merge the two data set into one merged_data data frame by the two columns where they share content.

# splitting multiple countries in "Country" column into separate rows
articles$Country <- strsplit(articles$Country, ", ")

# unnesting to convert array into set of rows 
articles <- unnest(articles, Country)

# merging articles and countries based on country column
merged_data <- merge(articles, countries, by.x = "Country", by.y = "ADMIN", all.x = TRUE)
merged_data
    Country
1 Australia
2 Australia
3   Belgium
4    Brazil
5    Brazil
6     China
                                                                                                                                                                                                                                                           Author
1                                                                                                                                                                                                               Newton, Joanna E.; Nettle, Ruth; Pryce, Jennie E.
2                                                                                        Fielke, Simon J.; Taylor, Bruce M.; Jakku, Emma; Mooij, Martijn; Stitzlein, Cara; Fleming, Aysha; Thorburn, Peter J.; Webster, Anthony J.; Davis, Aaron; Vilas, Maria P.
3                                                                                     Barnes, Andrew; De Soto, Iria; Eory, Vera; Beck, Bert; Balafoutis, Athanasios; Sánchez, Berta; Vangeyte, Jürgen; Fountas, Spyros; van der Wal, Tamme; Gómez-Barbero, Manuel
4 Bolfe, Édson Luis; Jorge, Lúcio André de Castro; Sanches, Ieda Del’Arco; Júnior, Ariovaldo Luchiari; Costa, Cinthia Cabral da; Victoria, Daniel de Castro; Inamasu, Ricardo Yassushi; Grego, Célia Regina; Ferreira, Victor Rodrigues; Ramirez, Andrea Restrepo
5                                                                                                                                                                                         Colussi, Joana; Morgan, Eric L.; Schnitkey, Gary D.; Padula, Antônio D.
6                                                                                                                                                                                                                                     Zhang, Xiufan; Fan, Decheng
  Year
1 2020
2 2021
3 2019
4 2020
5 2022
6 2023
                                                                                                                                     Title
1                           Farming smarter with big data: Insights from the case of Australia's national dairy herd milk recording scheme
2                                             Grasping at digitalisation: turning imagination into fact in the sugarcane farming community
3           Influencing factors and incentives on the intention to adopt precision agricultural technologies within arable farming systems
4                                          Precision and digital agriculture: Adoption of technologies and perception of Brazilian farmers
5                                 How Communication Affects the Adoption of Digital Technologies in Soybean Production: A Survey in Brazil
6 Can agricultural digital transformation help farmers increase income? An empirical study based on thousands of farmers in Hubei Province
                                      Journal
1                        Agricultural Systems
2                      Sustainability Science
3            Environmental Science and Policy
4                   Agriculture (Switzerland)
5                   Agriculture (Switzerland)
6 Environment, Development and Sustainability
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Abstract
1                                                                                                                                                                                                                                      This paper explores the use of big data in Australia's dairy industry and factors influencing farmer engagement. It identifies important dimensions of farmer demand for big data applications and highlights critical attributes of support services. The findings contribute to understanding collaborative governance arrangements that support farm engagement with big data.
2                                                                    This paper addresses nutrient runoff in Australia's Great Barrier Reef and the use of water quality monitoring and digital technology to mitigate the issue. It emphasizes the role of sugar cane farmers and the agricultural knowledge network in promoting sustainability. The concept of digi-grasping is introduced, along with the digi-MAST framework for assessing digital engagement and transformation. The framework guides the allocation of resources and actions for maximizing the impact of digital technological research outputs.
3 This study explores the adoption of precision agriculture technologies (PATs) among European farmers. A survey of 971 farmers in five countries reveals differences between current adopters and non-adopters of PATs. Non-adopters have more confidence in their field knowledge and are generally older. Non-adopters intending to adopt PATs in the future are more open to incentives. Attitudes towards investment certainty and payback periods vary. These findings suggest a gradient of adoption in European arable farming, requiring targeted policy interventions for sustainable agricultural production.
4                                                                                                                                                                                                                             This article presents survey results from 504 Brazilian farmers on the use of digital technologies in agriculture. 84% of farmers reported using at least one digital technology, with increased productivity being the main benefit and acquisition costs as the primary challenge. The majority expressed interest in learning more about new technologies for agricultural development.
5                                                                                                                                               This article presents survey results from 461 Brazilian soybean farmers on technology adoption. It found that communication channels, including social media and in-person activities, influence the use of precision and digital technologies. LinkedIn showed the highest positive correlation, while conferences and seminars were linked to perceived benefits. The study emphasizes the importance of knowledge and information in agriculture technology adoption.
6                                                                                                                             This study explores the impact of agricultural digitization on farmers' income in China. Based on a survey of 1500 farmers in Hubei Province, it finds that agricultural digitization promotes income increase by improving production efficiency, expanding sales channels, and upgrading agricultural structure. The findings provide theoretical references and guidance for promoting agricultural digitization and increasing farmers' income in the context of rural revitalization.
                                                                                                       Keywords
1                              Collaborative governance; Farm decision making; Herd testing; Livestock genomics
2                      Agriculture; Digital technology; Responsible innovation; Social science; User experience
3                           Arable farming; Incentives; Precision agriculture; Zero inflated Poisson regression
4                                                    Agriculture 4.0; Brazil; Farmer’s attitudes; Smart farming
5              Brazilian soybean farmers; Interpersonal meetings; Mass media; Social media; Technology adoption
6 Agricultural structure; Digitalization of agriculture; Farmers’ income; Production efficiency; Sales channels
  Questionnaire/Interview
1                      No
2                     Yes
3                     Yes
4                     Yes
5                     Yes
6                     Yes
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         URL
1                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             https://www.sciencedirect.com/science/article/pii/S0308521X19309758?via%3Dihub
2                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 https://link.springer.com/article/10.1007/s11625-020-00885-9?utm_source=getftr&utm_medium=getftr&utm_campaign=getftr_pilot
3                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             https://www.sciencedirect.com/science/article/pii/S1462901118305471?via%3Dihub
4 https://com-mendeley-prod-publicsharing-pdfstore.s3.eu-west-1.amazonaws.com/35d0-CC-BY-2/10.3390/agriculture10120653.pdf?X-Amz-Security-Token=IQoJb3JpZ2luX2VjEDwaCWV1LXdlc3QtMSJHMEUCIGORIX4nxGAJyZEVA%2FZxriZQp834txpQ43CiU8%2BLFuznAiEAw9brPfDA8GYeQ%2FoRtpk2yD7SJd2lU4rFtzH6P%2FgIAf4qgwQIdRAEGgwxMDgxNjYxOTQ1MDUiDGY1GMIvWXpFg93PcSrgA13shVaNRi1LaeX49ZOARSPrFAYHvJZL5hRk72vOp2f8cV3MTPBLW%2BQjgKhCWn8qBcoM7fAeFRu5docVyweGSeI0HH%2BjWLpGYxXAF8S3wedouOf3kDZt6CP5fwWjjKz%2BOIGWl3fiF0rAPIV3MPAUQ9Hd6XaO4MD3WtRb52yJEtrpI%2BOmtKEAijSkEAHWY50ge%2Bm0liV1R7aADo0fXHc6B6Y2N4GFikffOpLu4C%2FlTZEC3iZY08ld6MDagjFy%2FWyDKWWLn67mqLI39wjx8m5UN4UOM2kKo1eH3FyYa6DLM0PCJVfKehQswAnYOjkH%2Bo9whhJIDdqVZWMS3ehrmzieFIMjxXRMj9ovfxwvrpR4eLMdc6YnI12t6eiSpyxM8IM%2FgxcvxY2zOfNtRO12kG7a9i32ILXbo3OHdPqgBApPwdseq1YVTKBs2Zeu18wDNU1CJgJ8%2FTVYMjVuXWhrti2unLYfOuo3zqptMDiAsUmnamjocfP9I3DLXsMXYrZZL4sG4LDr9DVtiZuqgGks7iuW5wIFVzoHCGzISOPA2lK%2F5AsOQ7Nnznjuq9nMVXkQilQdwLUnRXwPdrzWsIuKe75NHwBcuZ2GTX2T3EGxR3Aeu9QQWnjfC44c9KeC8Ty0RSjEADCtm9KjBjqlAWu3e%2FMSn4ijeq6D3j3hvWvDATiYHiK%2BE1Sv1%2F0NXgC2dtJemcBaMaweIHGoQljzqDuvdaoht8NYbFnflmZAHuLGuv57Xejcx5gy%2BCJekGYHtMHEa5bGSlJrvkr5xHWf4JyCyBwXakUVTL1DWUoG8emuvWOu%2B2d4eCJbWwJhKfmsgRWHT%2BC0nJbgTrlqSmtuZ1Wf03qYOKKa9Ki%2B8DM%2Bxx6A54tDng%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20230529T132235Z&X-Amz-SignedHeaders=host&X-Amz-Expires=300&X-Amz-Credential=ASIARSLZVEVEVTCLGLE2%2F20230529%2Feu-west-1%2Fs3%2Faws4_request&X-Amz-Signature=1e14b79fc3874c1bdb36a3922e01eb79a29accfe02a58c1e09c303d6f0fb2b39
5                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 https://www.scopus.com/record/display.uri?eid=2-s2.0-85129595088&origin=resultslist&sort=r-f&src=s&nlo=&nlr=&nls=&mltEid=2-s2.0-85034219155&mltType=ref&mltAll=t&imp=t&sid=c950ff64272bfbaea0acd15525f956c5&sot=mlt&sdt=mlt&sl=581&s=REFEID%28%28%222-s2.0-84917674245%22%29+OR+%28%222-s2.0-0043202913%22%29+OR+%28%222-s2.0-0022167588%22%29+OR+%28%222-s2.0-17844404856%22%29+OR+%28%222-s2.0-84868616377%22%29+OR+%28%222-s2.0-85042086087%22%29+OR+%28%222-s2.0-79251616186%22%29+OR+%28%222-s2.0-84936774736%22%29+OR+%28%222-s2.0-79957668921%22%29+OR+%28%222-s2.0-85042092753%22%29+OR+%28%222-s2.0-85042092236%22%29+OR+%28%222-s2.0-84864044035%22%29+OR+%28%222-s2.0-17844367019%22%29+OR+%28%222-s2.0-84947276090%22%29+OR+%28%222-s2.0-84911910116%22%29+OR+%28%222-s2.0-58349092555%22%29+OR+%28%222-s2.0-79953782320%22%29+OR+%28%222-s2.0-33748874009%22%29+OR+%28%222-s2.0-85042100227%22%29+OR+%28%222-s2.0-84868627114%22%29+OR+%28%222-s2.0-85042137331%22%29%29+AND+NOT+EID+%282-s2.0-85034219155%29&relpos=34&citeCnt=3&searchTerm=
6                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 https://link.springer.com/article/10.1007/s10668-023-03200-5?utm_source=getftr&utm_medium=getftr&utm_campaign=getftr_pilot
  ISO_A3                       geometry
1    AUS MULTIPOLYGON (((158.8657 -5...
2    AUS MULTIPOLYGON (((158.8657 -5...
3    BEL MULTIPOLYGON (((4.815447 51...
4    BRA MULTIPOLYGON (((-48.54259 -...
5    BRA MULTIPOLYGON (((-48.54259 -...
6    CHN MULTIPOLYGON (((111.2046 15...
 [ reached 'max' / getOption("max.print") -- omitted 64 rows ]

When inspecting the merged_data data frame is appears as if all the columns from the two data files have merged successfully. This data frame only contains the countries and ISO codes of the countries which first appeared in the articles file.

# calculating frequency count of each country
country_counts <- table(merged_data$Country)

# converting frequency counts to data frame
counts_df <- data.frame(Country = names(country_counts), Count = as.numeric(country_counts))
counts_df
                    Country Count
1                 Australia     2
2                   Belgium     1
3                    Brazil     2
4                     China     1
5            Czech Republic     1
6                   Denmark     3
7                   Finland     1
8                    France     2
9                   Germany    12
10                    Ghana     1
11                   Greece     3
12                  Hungary     4
13                    India     1
14                    Italy     7
15                   Latvia     1
16               Madagascar     1
17              Netherlands     1
18              New Zealand     2
19                   Norway     1
20                   Poland     1
21                   Russia     5
22                   Rwanda     1
23                 Slovenia     1
24                    Spain     2
25              Switzerland     6
26                   Taiwan     1
27                   Turkey     1
28                  Ukraine     1
29           United Kingdom     1
30 United States of America     3
# getting top five countries with highest number of studies
top_countries <- counts_df %>%
  arrange(desc(Count)) %>%
  head(5)

# merging country counts with countries GeoJSON data
merged_geojson <- merge(countries, counts_df, by.x = "ADMIN", by.y = "Country", all.x = TRUE)
merged_geojson
Simple feature collection with 255 features and 3 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -180 ymin: -90 xmax: 180 ymax: 83.6341
Geodetic CRS:  WGS 84
First 10 features:
                          ADMIN ISO_A3 Count                       geometry
1                   Afghanistan    AFG    NA MULTIPOLYGON (((71.0498 38....
2  Akrotiri Sovereign Base Area    -99    NA MULTIPOLYGON (((32.84081 34...
3                         Aland    ALA    NA MULTIPOLYGON (((20.92018 59...
4                       Albania    ALB    NA MULTIPOLYGON (((19.74777 42...
5                       Algeria    DZA    NA MULTIPOLYGON (((8.60251 36....
6                American Samoa    ASM    NA MULTIPOLYGON (((-168.1605 -...
7                       Andorra    AND    NA MULTIPOLYGON (((1.707006 42...
8                        Angola    AGO    NA MULTIPOLYGON (((11.73752 -1...
9                      Anguilla    AIA    NA MULTIPOLYGON (((-63.03767 1...
10                   Antarctica    ATA    NA MULTIPOLYGON (((-162.409 -8...

Choropleth map

# defining color palette
color_palette <- brewer.pal(9, "Greens")

# create leaflet map
map <- leaflet(data = merged_geojson) %>%
  setView(lng = 0, lat = 0, zoom = 2) %>%
  addProviderTiles("OpenStreetMap.Mapnik") %>%
  addPolygons(fillColor = ~colorNumeric(color_palette, domain = Count)(Count),
              weight = 1,
              opacity = 1,
              color = "white",
              fillOpacity = 0.7,
              highlight = highlightOptions(
                weight = 2,
                color = "white",
                fillOpacity = 0.9
              ),
              label = ~paste(ADMIN, ": ", Count)) %>%
  addLegend("bottomright", pal = colorNumeric(color_palette, domain = unique(counts_df$Count)), values = unique(counts_df$Count), title = "Count") %>%
  addControl(html = as.character(tags$div(HTML(paste0("<h4>Top 5 Countries</h4>",
                                                      "<table>",                                                      "<thead><tr><th>Country</th><th>Count</th></tr></thead>",
                                                      "<tbody>",
                                                      paste0("<tr><td>", top_countries$Country, "</td><td>", top_countries$Count, "</td></tr>", collapse = "\n"),
                                                      "</tbody>",
                                                      "</table>")))),
              position = "bottomleft") %>%
  addControl(html = as.character(tags$div(id = "map-title", style = "background-color: white; padding: 10px; font-family: Arial, sans-serif; font-size: 16px; font-weight: bold;", "World map of studies in Smart Farming")),
              position = "topright")
# displaying choropleth map
map

Centroid map

# Repair invalid geometries
merged_geojson <- st_make_valid(merged_geojson)

# Simplify country geometries
simplified_geojson <- st_simplify(merged_geojson, preserveTopology = TRUE, dTolerance = 0.01)

# Create centroids for each country
centroids <- st_centroid(simplified_geojson)

# Extract coordinates from centroids
centroids <- st_coordinates(centroids)

# Convert to data frame
centroids_df <- as.data.frame(centroids)

# Rename the columns
colnames(centroids_df) <- c("x", "y")

# Combine with the count data
centroids_df <- cbind(centroids_df, Count = simplified_geojson$Count)
# Create the bubble map
ggplot() +
  geom_sf(data = countries, fill = "grey", alpha = 0.3) +
  new_scale("size") +
  geom_point(data = centroids_df, aes(x = x, y = y, size = Count, color = Count), alpha = 0.7) +
  scale_size(range = c(1, 10), name = "Count") +
  scale_color_gradient(low = "blue", high = "red", name = "Count") +
  theme_void() +
  coord_sf() +
  labs(title = "World Map of Studies in Smart Farming") +
  theme(plot.title = element_text(hjust = 0.5, size = 16)) +
  guides(color = guide_legend(override.aes = list(size = 3))) +
  guides(size = FALSE)